#ifndef __SLOTHTTPD_HTTP_RESPONSE_HPP__
#define __SLOTHTTPD_HTTP_RESPONSE_HPP__

#include <slothttpd/types.hpp>
#include <slothttpd/http/status.hpp>
#include <slothttpd/http/header/responce.hpp>

#include <vector>
#include <string>
#include <ostream>

#include <sys/uio.h> // IOV_MAX

#include <boost/asio/buffer.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/array.hpp>

#define RESPONSE_MAX_BUFFERS (IOV_MAX < 64 ? IOV_MAX : 64)

namespace slothttpd {
namespace http {

class response
{
    friend std::ostream &operator<<(std::ostream &os, const response &r);
public:
    response();
    
    // TODO: add send(socket, callback) method
    
    // TODO: rework
    void push_back(boost::asio::const_buffer buffer);
    const_buffer_range_t get_buffers_range();
    
    void status_line(char_range_t line);
    void status_line(const std::string& line);
    
private:
    char_range_t status_line_;
    boost::array<boost::asio::const_buffer, RESPONSE_MAX_BUFFERS> buffers_;
    std::size_t buffer_count_;
};

}
}

#endif
